support parallel vtesto from qmake. (#612)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Mon, 27 Jul 2020 23:16:33 +0000 (17:16 -0600)
committerGitHub <noreply@github.com>
Mon, 27 Jul 2020 23:16:33 +0000 (17:16 -0600)
* support parallel vtesto from qmake.

also support testo, vtesto with out of source builds.

* force check to run.

GPSBabel.pro
Makefile_vtesto [new file with mode: 0644]
f90g_track.cc
reference/nonexistent.err
reference/nonexistent_alternate.err
reference/track/f90g-sample.gpx
src/core/file.h
testo
testo.d/xol.test

index 9444222061b59126faaa5816cb227dbd6d5709de..60c6bc7f533bcfb7876c74e668ddffffea19411b 100644 (file)
@@ -215,11 +215,14 @@ DEFINES += CSVFMTS_ENABLED
 QMAKE_CFLAGS_WARN_ON -= -W
 QMAKE_CXXFLAGS_WARN_ON -= -W
 
-macx|linux|openbsd{
-  check.commands = PNAME=./$(TARGET) ./testo
-  check.depends = $(TARGET)
-  QMAKE_EXTRA_TARGETS += check
-}
+check.depends = $(TARGET) FORCE
+check.commands = @PNAME=./$(TARGET) $${PWD}/testo
+QMAKE_EXTRA_TARGETS += check
+
+check-vtesto.depends = $(TARGET) FORCE
+check-vtesto.commands += @$(MAKE) -s -f $${PWD}/Makefile_vtesto srcdir=$${PWD} builddir=$${OUT_PWD} check-vtesto
+QMAKE_EXTRA_TARGETS += check-vtesto
+QMAKE_CLEAN += $${OUT_PWD}/testo.d/*.vglog
 
 # build the compilation data base used by clang tools including clang-tidy.
 macx|linux|openbsd{
diff --git a/Makefile_vtesto b/Makefile_vtesto
new file mode 100644 (file)
index 0000000..4d65d69
--- /dev/null
@@ -0,0 +1,34 @@
+#
+# Legacy makefile hook for GPSBabel.pro
+# This lets us determine the tests when make is run instead
+# of when qmake is run.
+# The make parallel execution feature can be used.
+#
+# GPSBabel requires a reasonably recent version of GNU Make.
+# We rely on very few fancy features of make so the exact version
+# probably doesn't much matter.  GNU Make 3.81 seems a reasonable target.
+#
+
+srcdir = .
+builddir = .
+
+TESTCASES := $(sort $(wildcard $(srcdir)/testo.d/*.test))
+VGLOGS := $(addprefix $(builddir)/testo.d/, $(addsuffix .vglog, $(basename $(notdir $(TESTCASES)))))
+
+%.vglog: FORCE
+       @mkdir -p $(builddir)/testo.d
+       @$(srcdir)/vtesto -l -j $@ $(basename $(notdir $@))
+
+# Declaring a target PHONY whose names matches a subdirectory can be
+# particularly important, e.g. gui.
+.PHONY: all clean check-vtesto
+
+all: check-vtesto
+
+clean:
+       rm -f $(VGLOGS)
+
+check-vtesto:
+       @$(MAKE) -f $(srcdir)/Makefile_vtesto $(VGLOGS)
+
+FORCE:
index 90be17faff67002042fb1ded59d40a549e7950f5..1ea72c7a40fc635b96484ca4cf65f3a848c856d0 100644 (file)
@@ -29,6 +29,7 @@
 #include "defs.h"
 #include "gbfile.h"
 #include <QtCore/QDebug>
+#include <QtCore/QFileInfo>
 
 #define MYNAME "f90g_track"
 #define TTRECORDSIZE      249
@@ -69,7 +70,7 @@ f90g_track_rd_init(const QString& fname)
     // start the track list
     track = new route_head;
     is_fatal((track == nullptr), MYNAME ": memory non-enough");
-    track->rte_name = fname;
+    track->rte_name = QFileInfo(fname).fileName();
     track_add_head(track);
   }
 }
index 6a99096045a5347b45658082b43f470ab7372773..503ad75ac3d23c4b17d8a606407e58054065e07f 100644 (file)
@@ -1 +1 @@
-Cannot open './reference/doesnotexist' for read.  Error was 'No such file or directory'.
+Cannot open 'doesnotexist' for read.  Error was 'No such file or directory'.
index 38376665ac083e7138d0ffba8d00b2fdf6544346..2f3890dbbeb108c2444574fa72877c4689b58102 100644 (file)
@@ -1 +1 @@
-Cannot open './reference/doesnotexist' for read.  Error was 'The system cannot find the file specified.'.
+Cannot open 'doesnotexist' for read.  Error was 'The system cannot find the file specified.'.
index 12bc4339044b8a3b8c35d4020159bde1301d4fd2..1f1a449ee82976265518fcac26898ee242dd6a82 100644 (file)
@@ -3,7 +3,7 @@
   <time>1970-01-01T00:00:00Z</time>
   <bounds minlat="40.804915000" minlon="-124.126895000" maxlat="40.847798333" maxlon="-124.082008333"/>
   <trk>
-    <name>./reference/track/f90g-sample.map</name>
+    <name>f90g-sample.map</name>
     <trkseg>
       <trkpt lat="40.847798333" lon="-124.082008333">
         <time>2014-04-27T17:39:52Z</time>
index 60c5d2c8e9a3d161a7dfcd882882f2faf263781e..c6cd70d17fbd918697936546229195e8624a5989 100644 (file)
@@ -21,6 +21,7 @@
 #define SRC_CORE_FILE_INCLUDED_H_
 
 #include <QtCore/QFile>
+#include <QtCore/QFileInfo>
 #include <QtCore/QIODevice>
 #include <cstdio>
 #include "defs.h"
@@ -51,7 +52,7 @@ public:
 
     if (!status) {
       fatal("Cannot open '%s' for %s.  Error was '%s'.\n",
-            qPrintable(QFile::fileName()),
+            gpsbabel_testmode()? qPrintable(QFileInfo(*this).fileName()) : qPrintable(QFile::fileName()),
             (mode & QIODevice::WriteOnly)? "write" : "read",
             qPrintable(QFile::errorString()));
     }
diff --git a/testo b/testo
index be5444c0df5c2ce34ef8f121a971248228cfb891..b4ff2c5023c176d51b72811e7df41c6fd4f55ec7 100755 (executable)
--- a/testo
+++ b/testo
@@ -137,14 +137,14 @@ if [ $# -ge 1 ]; then
   while [ $# -ge 1 ];
   do
     t=${BASEPATH}/testo.d/$1.test
-    echo Running $t
+    echo Running `basename $t`
     . $t
     shift;
   done
 else
   for i in ${BASEPATH}/testo.d/*.test
   do
-    echo Running $i
+    echo Running `basename $i`
     . $i
   done
 fi
index b4135a89936aa70647fa538cb25a0066f10f1297..94f69450da78696f851025219d7f571489b36b2b 100644 (file)
@@ -15,10 +15,8 @@ rm -f ${TMPDIR}/xol-sample_si.gpx
 ${PNAME} -i xol -f ${REFERENCE}/doesnotexist -o gpx -F ${TMPDIR}/xol-sample_si.gpx 2> ${TMPDIR}/nonexistent.err && {
          echo "${PNAME} succeeded! (it shouldn't have with this input...)"
 }
-# check error message is what we expected
-# Note that the reference file nonexistent.err includes the file path,
-# so this will fail when starting from a directory other than gpsbabel.
-# the message can vary depending on the c runtime, .i.e. msvc and gcc are slightly different.
+# check error message is what we expected.
+# The message can vary depending on the c runtime, .i.e. msvc and gcc are slightly different.
 compare_with_alternate ${REFERENCE}/nonexistent.err ${REFERENCE}/nonexistent_alternate.err ${TMPDIR}/nonexistent.err